﻿using MvcApplication;
using MvcApplication.service;
using MvcEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace WebApplication4MVC.Controllers
{
    public class RoleController : CommonController
    {
        DemoRoleService roleService = new DemoRoleService();

        // GET: Role
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Add(RoleInfo request) {
            if (request==null)
            {
                return Json(CreateResponseReslut.CreateFail("参数错误"));
            }
            if (string.IsNullOrWhiteSpace(request.RoleName))
            {
                return Json(CreateResponseReslut.CreateFail("角色名称错误"));
            }
            try
            {
                var result = roleService.addRole(request);
                return Json(result);
            }
            catch (Exception ex)
            {
                MvcCommon.Log.Fatal($"新增角色错:{ex}");
            }
            return Json(CreateResponseReslut.CreateFail("系统繁忙"));
           
        }
    }
}